let navsecond = document.querySelector('.nav-second-body')
ajax({
  method: "get",
  url: "stage-api/website/getProductMenuInfo",
  success: function(res){
    console.log(res)
    for (let i = 0; i < res.data.length; i++) {
      if (i == 4) {
        continue;
      }else if(i == 6){
        continue;
      }else{
         navsecond.innerHTML += `<li class="nav-second-item" onclick="detail('${res.data[i].productId}')">
                                <div class="navsec-bod">
                                  <img src="${res.data[i].menuIcon.split("?")[0]}">
                                  <div>${res.data[i].productName}</div>
                                </div>
                              </li>`
      }
    }
  }
})

function detail(productId) {
      location.href = `product.html?productId=${productId}`
    }


let lefttitle = document.querySelector('.body-left-title')
let lefttext = document.querySelector('.body-left-text')
ajax({
  method: "get",
  url: "stage-api/website/getProductDetails",
  params:{
    productId: 13,
  },
  success: function(res) {
    lefttitle.innerText =  `${res.data.productDetails.productName}`
    lefttext.innerHTML = `${res.data.productDetails.productIntroduce}`
  }
})


let righttext = document.querySelector('.body-right-text .text-body')
ajax({
  method: "get",
  url: "stage-api/website/getProductDetails",
  params:{
    productId: 13,
  },
  success: function(res) {
    for (let i = 0; i < res.data.companies.length; i++) {
      if (i <= 5) {
        righttext.innerHTML += `<li class="item-wrap" onclick=casedetails('${res.data.companies[i].caseCompanyId}')>
                                <div class="item">
                                  <div class="item-left">
                                    <img src="${res.data.companies[i].companyLogoPhoto.split('?')[0]}">
                                  </div>
                                  <div class="item-right">
                                    <div class="item-text">${res.data.companies[i].caseCompanyName}</div>
                                    <div class="item-time">${res.data.companies[i].createTime.split(' ')[0]}</div>
                                  </div>
                                </div>
                              </li>`
      }else{
        break;
      }
    }
  }
})

function casedetails(caseCompanyId) {
  location.href = `casestudyshow.html?caseCompanyId=${caseCompanyId}`
}